<?php
$con=mysqli_connect("mysql3.000webhost.com","a3553940_treno","Ulisse77","a3553940_treno");
// Check connection
if (mysqli_connect_errno())
  {
  echo "-1";
  exit;
  }
$lat=(double)$_GET['lat'];
$lon=(double)$_GET['lon'];
//echo "<table>";
$result = mysqli_query($con,"SELECT * FROM STATION");
$arrayPos= array ();
$i=0;
while($row = mysqli_fetch_array($result))
  {
  $pos=sqrt(pow((double)$row['lon']-$lon,2)+pow((double)$row['lat']-$lat,2));
  $arrayPos[$i][0]=$pos;
  $arrayPos[$i][1]=$row['station']; 
  $i=$i+1;
  }

sort($arrayPos);
echo $arrayPos[0][1];
mysqli_close($con);
?>